#include <stdio.h>
 double pow(double x, int n) {
        if(x == 0 && n > 0)
            return 0;
        if(x == -1)
            return n%2 ? -1 : 1;
        if(x == 1)
            return 1;
        if(n < 0)
            return 1/pow(x, -n); 
        if(n == 0)
            return 1;
        if(n == 1)
            return x;
        if(n == 2)
            return x*x;
        return(pow(pow(x, n/2),2)*pow(x,n%2));
    }
int main(int argc, char const *argv[])
{
    double result = 0;
    double data = -1;
    int powtime = 147483648;
    result = pow(data, powtime);
    printf("%lf ^ %d = %lf\n", data, powtime, result);
    return 0;
}